<template>
	<view>
	
		<view class="cont">
			<view class="cake-item" v-for="(item,index) in paperList" > 
			
				<view class="poster" @tap="handleDetail(item.id)">
					<image item.iaddress :src="item.iaddress"></image>
				</view>
				
				<view class="info-cont">
				<view class="info"> 
					<view class="fs-28">
					{{item.title}}
					<!-- .stop 阻止事件冒泡 -->
					<text :class="['iconfont',agree[isagree]]" @tap.stop="agree1(item.id)">{{item.likenum}}</text> 
					<text :class="['iconfont','icon-pinglun1'] "></text>
					</view>
				</view>
					<view class="cart-btn"></view>
				</view>
				
				
			</view> 
			
			
		</view>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page:1,
				paperList:[],
				agree:['icon-dianzan',"icon-dianzan1"],
				isagree:0,
				Comment:[]
			}
		},
		methods: {
			handleDetail(idx){
				uni.navigateTo({
					url:'/pages/details/details?idx='+idx
				})
			},
			agree1(id){
				console.log("点赞")
				uni.request({
					            url: 'http://localhost:1010/article/agree', 
								method: 'POST',
					            data: {
					                 paperId:id,
					                 userId:1   //登陆后从本地获取
					             },
					              success: (res) => {
									  if( this.isagree==0){
										  this.isagree=1
									  }else{
										   this.isagree=0
									  }
					               
					              }
					       })
			}
		},
		onLoad() {
			let paperVo ={
				pageNum:this.page,
				pageSize:5 
			} 
			uni.request({
				            url: 'http://localhost:1010/article/getByPages', 
							method: 'POST',
				            data: {
				                 pageNum:this.page,
				                 pageSize:3
				             },
				              success: (res) => {
				                  console.log(res.data.data.data);
								  this.paperList=res.data.data.data;
				              }
				       })
				console.log(paperVo)
		},
		onPullDownRefresh() {
			this.page=this.page+1;
			
			let paperVo ={
				pageNum:this.page,
				pageSize:5 
			} 
			uni.request({
				            url: 'http://localhost:1010/article/getByPages', 
							method: 'POST',
				            data: {
				                 pageNum:this.page,
				                 pageSize:3
				             },
				              success: (res) => {
				                  console.log(res.data.data.data);
								  this.paperList=res.data.data.data;
				              }
				       })
				console.log(paperVo)
		}
		
	}
</script>
<style lang="scss">
	// @import '/hcomment/colorui/main.css';
	// @import '/hcomment/colorui/icon.css';
.cake-item{
	width: 350upx;
	.poster{ //图片样式
		height: 350upx;
		background-color: #f5f5f5;
	}
	.fs-28{
		margin-top: 24upx;
	}
	.fs-16{
		margin: 14upx;
	}
	.fs-18{
		margin-bottom: 22upx;
	}
}
.cont{ //布局
	display: flex;
	flex-wrap: wrap;
	padding: 15upx; //缝隙
	justify-content: space-between;
}
	.avatar{
		width: 150upx;
		height: 150upx;
		border-radius: 50%;
	}
	.info{
		margin-top: 10upx;
	}
</style>